package com.work.vo.main;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.work.constant.DictBizConstant;
import com.work.utils.BigDecimalSerializer;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictBizCache;

import java.math.BigDecimal;
import java.time.LocalDate;

/**
 * 综合统计转配VO
 *
 * @author ：dujianyu
 * @since ：Created in 2024/7/5 8:48
 */
@Data
public class TransferStatVO {

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(name = "ID",notes = "")
    private Long id ;

    @ApiModelProperty(value = "理货日期")
    private LocalDate tallyDate;

    @ApiModelProperty(value = "时间段")
    private String timeSpace;

    @ApiModelProperty(value = "时间段")
    private String timeSpaceName;

    public String getTimeSpaceName() {
        if (Func.isNull(timeSpace)) {
            return "";
        }
        return DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @ApiModelProperty(value = "时间信息")
    private String timeInfo;

    public String getTimeInfo() {
        if (Func.isNull(timeSpace) || Func.isNull(tallyDate)) {
            return "";
        }
        return tallyDate + "/" + DictBizCache.getValue(DictBizConstant.TIME_SPACE, timeSpace);
    }

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportShipId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long oriTransportBillId;

    @ApiModelProperty(name = "来源船名",notes = "")
    private String oriShipNameZh;

    @ApiModelProperty(name = "来源航次",notes = "")
    private String oriVoyage;

    @ApiModelProperty(value = "来源船信息")
    private String oriShipInfo;

    public String getOriShipInfo() {
        if (Func.isNull(oriShipNameZh) || Func.isNull(oriVoyage)) {
            return "";
        }
        return oriShipNameZh + "/" + oriVoyage;
    }

    @ApiModelProperty(name = "来源单号",notes = "")
    private String oriBillNo;

    @ApiModelProperty(name = "来源船货名",notes = "")
    private String oriBillCargoTypeName;

    @ApiModelProperty(name = "来源船包装",notes = "")
    private String oriPackageTypeName;

    @ApiModelProperty(value = "货场")
    private String positionName;

    @ApiModelProperty(value = "货位")
    private String spot;

    @ApiModelProperty(value = "货位")
    private String positionInfo;

    public String getPositionInfo() {
        if (Func.isNull(positionName) || Func.isNull(spot)) {
            return "";
        }
        return positionName + "/" + spot;
    }

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long toTransportShipId;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "id")
    private Long toTransportBillId;

    @ApiModelProperty(name = "来源船名",notes = "")
    private String toShipNameZh;

    @ApiModelProperty(name = "来源航次",notes = "")
    private String toVoyage;

    @ApiModelProperty(value = "来源船信息")
    private String toShipInfo;

    public String getToShipInfo() {
        if (Func.isNull(toShipNameZh) || Func.isNull(toVoyage)) {
            return "";
        }
        return toShipNameZh + "/" + toVoyage;
    }

    @ApiModelProperty(name = "来源单号",notes = "")
    private String toBillNo;

    @ApiModelProperty(value = "件数")
    private Integer oriPiece;

    @JsonSerialize(using = BigDecimalSerializer.class)
    @ApiModelProperty(value = "吨数")
    private BigDecimal oriTon;

    @ApiModelProperty(value = "件吨")
    private String oriPieceTonInfo;

    public String getOriPieceTonInfo() {
        if (Func.isNull(oriPiece) || Func.isNull(oriTon)) {
            return "";
        }
        return oriPiece + "/" + oriTon.stripTrailingZeros().toPlainString();
    }

    @ApiModelProperty(value = "创建人")
    private String createUserName;
}
